package com.linxz.wandnroid.presenter;


import com.linxz.framework.base.ActivityLifeCycleEvent;
import com.linxz.framework.base.presenter.BasePresenter;
import com.linxz.framework.protocol.callback.ModelCallBack;
import com.linxz.wandnroid.appui.view.GankHomeView;
import com.linxz.wandnroid.module.WanAndroidModule;
import com.linxz.wandnroid.pojo.resp.GankResp;

import io.reactivex.subjects.PublishSubject;

/**
 * @author Linxz
 * 创建日期：2020年02月28日 11:41
 * version：v4.5.4
 * 描述：
 */
public class GankHomePresenter extends BasePresenter<GankHomeView, WanAndroidModule> {

    public GankHomePresenter(GankHomeView mView, PublishSubject<ActivityLifeCycleEvent> lifecycleSubject) {
        super(mView, lifecycleSubject);
    }

    @Override
    public WanAndroidModule createModel(PublishSubject<ActivityLifeCycleEvent> lifecycleSubject) {
        return new WanAndroidModule(lifecycleSubject);
    }

    public void getGank(){
        mModel.getGankList(new ModelCallBack<GankResp>() {
            @Override
            public void onSuccess(GankResp model) {
                mView.onLoadSuccess(model.getCategory(),model.getData());
            }

            @Override
            public void onErrors(String code, String msg) {
               mView.onLoadError(msg);
            }
        });
    }
}
